/* ==========================================================================
   TABLES
   ========================================================================== */

.data-list-header {
    @apply px-4 py-3 flex flex-wrap items-center;
}

.data-list-search-input {
	/*  @apply text-sm px-4 py-2 flex-1 rounded border; */
	@apply bg-white;

	&:focus {
		@apply focus-outline;
	}
}

.data-list-bulk-actions {
	@apply bg-white dark:bg-dark-750 absolute w-full py-2 z-1;
	padding-left: 56px ; [dir="rtl"] & { padding-right: 56px ; padding-left: 0 ; }
}

.mode-grid .data-list-bulk-actions {
	@apply bg-white dark:bg-dark-800 w-full pt-3 pb-1 z-10 rtl:pr-4 ltr:pl-4 static;
}

.mode-grid .rotating-dots-button {
    @apply bg-white dark:bg-dark-400;
}

.data-list-footer {
    @apply py-3 rtl:pl-4 ltr:pr-4 flex items-center border-t;
}

.data-table {
	@apply rtl:text-right ltr:text-left text-gray-700 dark:text-dark-150 outline-none max-w-full w-full;
	overflow-x: auto;

    thead {
		@apply bg-gray-100 text-xs text-gray-900;
        @apply dark:bg-dark-700 dark:text-dark-100;

		tr {
			@apply border-b dark:border-dark-900;
		}

        th {
            @apply font-medium px-4 py-3 whitespace-nowrap;
            &:first-child { @apply rtl:rounded-tr-lg ltr:rounded-tl-lg; }
			&:last-child { @apply rtl:rounded-tl-lg ltr:rounded-tr-lg; }
			&:hover {
				@apply text-gray-900 dark:text-dark-100;
			}
		}
        th.handle-column {
            @apply p-0 w-4;
        }
		.type-column {
			@apply ltr:text-right rtl:text-left;
		}
	}

    tbody {
		outline: none;
        tr {
			@apply border-b border-gray-400 dark:border-dark-900 text-sm;

			&.row-selected {
				@apply bg-gray-200 dark:bg-dark-600;
			}

			&:first-child {
				td:first-child, th:first-child {
				    @apply rtl:rounded-tr-md ltr:rounded-tl-md;
				}

				td:last-child, th:last-child {
				    @apply rtl:rounded-tl-md ltr:rounded-tr-md;
				}
			}

			&:last-child {
				@apply border-none;

                td:first-child, th:first-child {
				    @apply rtl:rounded-br-md ltr:rounded-bl-md;
				}

				td:last-child, th:last-child {
				    @apply rtl:rounded-bl-md ltr:rounded-br-md;
				}
			}

            &:hover {
                @apply bg-gray-100 dark:bg-dark-575;
            }

            th {
                @apply py-2 rtl:pl-4 ltr:pr-4;
            }

            td {
                @apply py-2 px-4 break-words;
            }

            td.table-drag-handle {
                @apply w-1 rtl:border-l ltr:border-r h-full py-2 px-0;
            }
		}

        .type-column {
			@apply ltr:text-right rtl:text-left;
		}
    }


    .sortable-column {
        @apply cursor-pointer select-none;

        &:hover {
			@apply text-blue-500 dark:text-dark-blue-100;
        }

        &.current-column {
            svg { opacity: 1; }
        }

        svg {
            opacity: 0;
        }

        svg.asc {
            transform: scaleY(-1);
        }
	}

    .date-index-field {
        @apply whitespace-nowrap;
    }
}

/* Sticky Meta Columns */
.data-table {
    thead th.checkbox-column {
        @apply p-0 rtl:pl-2 ltr:pr-2 sticky z-1 rtl:-right-px ltr:-left-px;
        width: 45px;
        min-width: 45px;
        &:after {
            @apply absolute rtl:right-0 ltr:left-0 rtl:left-0 ltr:right-0 top-0 bottom-0 -z-1 ;
            content: '';
            background-image: linear-gradient(to right, theme(colors.gray.100) 70%, theme(colors.gray.100 / 0%) 100%);

            .dark & {
                background-image: linear-gradient(to right, theme(colors.dark.550) 70%, theme(colors.dark.550 / 0%) 100%);
            }
        }

        &:has(input:checked) {
            &:after {
                .dark & {
                    background-image: linear-gradient(to right, theme(colors.dark.750) 70%, theme(colors.dark.750 / 0%) 100%);
                    @apply border-b border-dark-550;
                }
            }
        }
    }

    thead th.actions-column {
        @apply p-0 rtl:pr-2 ltr:pl-2 rtl:text-left ltr:text-right sticky rtl:-left-px ltr:-right-px;
        width: 45px;
        min-width: 45px;
        &:after {
            @apply absolute rtl:right-0 ltr:left-0 rtl:left-0 ltr:right-0 top-0 bottom-0 -z-1;
            content: '';
            background-image: linear-gradient(to left, theme(colors.gray.100) 70%, theme(colors.gray.100 / 0%) 100%);

            .dark & {
                background-image: linear-gradient(to left, theme(colors.dark.550) 70%, theme(colors.dark.550 / 0%) 100%);
            }
        }

        &:has(input:checked) {
            &:after {
                .dark & {
                    background-image: linear-gradient(to left, theme(colors.dark.750) 70%, theme(colors.dark.750 / 0%) 100%);
                    @apply border-b border-dark-550;
                }
            }
        }
    }

    tbody th.checkbox-column {
        @apply px-3 sticky rtl:-right-px ltr:-left-px;
        &:after {
            @apply absolute rtl:right-0 ltr:left-0 rtl:left-0 ltr:right-0 top-0 bottom-0 -z-1;
            content: '';
            background-image: linear-gradient(to right, rgba(255,255,255,1) 70%, rgba(255,255,255,0) 100%);

            .dark & {
                background-image: linear-gradient(to right, theme(colors.dark.600) 70%, theme(colors.dark.600 / 0%) 100%);
            }
        }
    }

    tbody th.actions-column {
        @apply p-0 rtl:pr-2 ltr:pl-2 rtl:text-left ltr:text-right sticky rtl:-left-px ltr:-right-px;
        min-width: 45px;
        width: 45px;
        &:after {
            @apply absolute rtl:right-0 ltr:left-0 rtl:left-0 ltr:right-0 top-0 bottom-0 -z-1;
            content: '';
            background-image: linear-gradient(to left, rgba(255,255,255,1) 70%, rgba(255,255,255,0) 100%);

            .dark & {
                background-image: linear-gradient(to left, theme(colors.dark.600) 70%, theme(colors.dark.600 / 0%) 100%);
            }
        }
    }

    tbody tr.row-selected .checkbox-column:after {
        background-image: linear-gradient(to right, theme(colors.gray.200) 70%, theme(colors.gray.200 / 0%) 100%);

        .dark & {
            background-image: linear-gradient(to right, theme(colors.dark.600) 70%, theme(colors.dark.600 / 0%) 100%);
        }
    }

    tbody tr.row-selected .actions-column:after {
        background-image: linear-gradient(to left, theme(colors.gray.200) 70%, theme(colors.gray.200 / 0%) 100%);

        .dark & {
            background-image: linear-gradient(to left, theme(colors.dark.600) 70%, theme(colors.dark.600 / 0%) 100%);
        }
    }

    tbody tr:hover .checkbox-column:after {
        background-image: linear-gradient(to right, theme(colors.gray.100) 70%, theme(colors.gray.100 / 0%) 100%);

        .dark & {
            background-image: linear-gradient(to right, theme(colors.dark.500) 70%, theme(colors.dark.500 / 0%) 100%);
        }
    }

    tbody tr:hover .actions-column:after {
        background-image: linear-gradient(to left, theme(colors.gray.100) 70%, theme(colors.gray.100 / 0%) 100%);

        .dark & {
            background-image: linear-gradient(to left, theme(colors.dark.500) 70%, theme(colors.dark.500 / 0%) 100%);
        }
    }
}


.data-list-header ~ .data-table {
    thead th {
        border-radius: 0;
    }
}

.data-list-filter-link {
	@apply border-gray-400 dark:border-dark-900 text-gray-600 dark:text-dark-150 rtl:ml-2 ltr:mr-2 p-3 pb-2;

	&:hover {
		@apply border-b-3 dark:border-dark-900 text-gray-700 dark:text-dark-100;
	}

	&:focus {
		@apply border-blue-300 dark:border-dark-blue-100;
		outline: 0;
		box-shadow: inset 0 0 0 0.2rem rgba(0,125,255,.25);
	}

	&.active {
		@apply border-b-3 border-blue dark:border-dark-blue-100 text-gray-800 dark:text-dark-100;
	}
}

td.table-drag-handle {
	@apply w-3 rtl:border-l ltr:border-r dark:border-dark-900 h-full p-2;
    min-width: 16px;
	cursor: grab;
	background: theme('colors.gray.200') url('../../svg/icons/light/drag-dots.svg') center center no-repeat;
    background-size: 7px 17px;

    .dark & {
        background-color: theme(colors.dark.700);
    }

	&:hover { @apply bg-gray-300 dark:bg-dark-750; }
}

.table-row-placeholder {
	background: hsla(210, 30%, 95%, 1);
}

.delete-column {
	background: #fff;
	border: 1px solid #ccc;
	border-radius: 22px;
	color: #777;
	box-shadow: 0 1px 1px rgba(0,0,0,.05);
	line-height: 1;
	text-align: center;
	height: 22px;
	width: 22px;
	float: right ; [dir="rtl"] & { float: left ; }
	cursor: pointer;

	&:hover {
		box-shadow: none;
		color: #555;
	}
}

.column-sortable {
	cursor: pointer;
	position: relative;

	&:before {
		content: "";
		position: absolute;
		bottom: -1px;
	 left: 0 ; [dir="rtl"] & { left: auto ; right: 0 ; }
	 right: 0 ; [dir="rtl"] & { right: auto ; left: 0 ; }
		height: 2px;
	}

	&:hover:before {
        @apply bg-gray-300;
	}
	&.active:before {
        @apply bg-blue;
    }
	.icon {
        position: relative;
        float: right ; [dir="rtl"] & { float: left ; }
        top: 6px;
        right: 5px ; [dir="rtl"] & { right: auto ; left: 5px ; }
	}

	.icon, .icon:before {
		line-height: 0;
	}
}

.column-status {
	text-align: center;
	width: 80px;
}

.column-actions {
	@apply ltr:text-right rtl:text-left;
	width: 30px;
}

table.control {
    @apply select-none;
}

.flush table.control {
    tr th:first-child {
        padding-left: 30px ; [dir="rtl"] & { padding-right: 30px ; padding-left: 0 ; }
    }
}


/* Index Fields
  ========================================================================== */

.bard-index-field,
.code-index-field,
.markdown-index-field,
.text-index-field,
.textarea-index-field {
    @apply line-clamp-2 text-xs;
}

.title-index-field {
    @apply line-clamp-2;
    min-width: 10vw;
}

.relationship-index-field {
    min-width: 10vw;
    .relationship-index-field-item {
        @apply rounded bg-gray-100 dark:bg-dark-500 border dark:border-dark-400 px-1 flex items-center text-2xs rtl:ml-1 ltr:mr-1;
        a {
            @apply line-clamp-1;
        }
    }
}

.date-index-field {
    @apply whitespace-nowrap text-gray-800 dark:text-dark-150;
}

.slug-index-field {
    @apply line-clamp-2 font-mono text-2xs;
}

.status-index-field {
    @apply inline-block text-xs bg-gray-300 dark:bg-dark-200 text-gray-800 dark:text-dark-150 shrink rounded-full px-2 py-0.5 text-center justify-center;

    &.status-published:not(.status-private) {
        @apply text-green-900 dark:text-green-950 bg-green-200 dark:bg-green-300;
    }

    &.status-scheduled {
        @apply text-amber-900 dark:text-amber-950 bg-amber-200 dark:bg-amber-300;
    }
}

.role-index-field, .groups-index-field {
    @apply flex flex-wrap -mb-1.5;

    .role-index-field-item,
    .groups-index-field-item {
        @apply rounded bg-gray-100 dark:bg-dark-700 border dark:border-dark-900 px-1 inline-block text-2xs line-clamp-1 mb-1;
    }
}
